using Godot;
using System;

public partial class HandChooseSlot : MarginContainer
{
	private Map _map;
	private Player _player;
	private SkillManager _skillManager;
	private ItemTile item_tile;
	public Item _item;
	private bool selectable;
	public Item item
	{
		get{ return _item; }
		set{
			item_setter(value);
		}
	}
	public void Initialize()
    {
        item_tile = (ItemTile)GetChild(0).GetChild(0);
		this.MouseEntered += OnMouseEntered;
		var Game = GetNode<Game>("/root/Game");
		_player = Game.get_player();
		_skillManager = _player.GetNode<SkillManager>("SkillManager");
    }
	public void item_setter(Item value)
	{
		_item = value;
		if (value != null)
		{
			item_tile.update_display(value);
			item_tile.Show();
		}
		else
		{
			item_tile.Hide();
		}
	}
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
	}

	public void OnMouseEntered()
	{
		if(item == null)
		{return; }
		(_player.CharacterData as PlayerData).LeftHand = item.name;
		_player.itemLeftHand = item;
		_skillManager.UpdataSkills();
	}

}
